package cn.itcast.tant_test;

import java.util.concurrent.*;

/**
 * @ClassName TestThread
 * @Description TODO
 * @Author tant
 * @Date 2025/5/16 10:01
 */
public class TestThread {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        new MyThread().start();

        new Thread(new MyRunnable()).start();

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("runnable2:outPut...");
            }
        };
        new Thread(runnable).start();


        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("runnable3:outPut...");
            }
        }).start();

        MyCallable myCallable = new MyCallable();
        FutureTask<Integer> ft = new FutureTask<>(myCallable);
        new Thread(ft).start();
        System.out.println(ft.get());

        ExecutorService executorService = Executors.newFixedThreadPool(1);
        Future<Integer> submit = executorService.submit(myCallable);
        System.out.println(submit.get());
        executorService.shutdown();

    }
}


class MyThread extends Thread {

    @Override
    public void run() {
        System.out.println("thread:outPut...");
    }
}

class MyRunnable implements Runnable {
    @Override
    public void run() {
        System.out.println("runnable1:outPut...");
    }
}

class MyCallable implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("callable:outPut...");
        return 99;
    }
}

    